TypeScript 2.x for Angular Developers by Christian Nwamba

TypeScript 2.x for Angular Developers by Christian Nwamba
Author: Christian Nwamba [Christian Nwamba]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2017-12-06

Data in components


To better understand the importance of services and DI, let's create a simple app with a component that shows a list of user comments. Once you have an app created, you can run the following command to generate the required component:

ng g component comment-list

Update the component's code with the following snippet:

import { Component, OnInit } from '@angular/core';

@Component({

selector: 'app-comment-list',

templateUrl: './comment-list.component.html',

styleUrls: ['./comment-list.component.css']

})

export class CommentListComponent implements OnInit {